#include <algorithm>
#include <cstdio>

typedef long long ll;
const int N = 500005;
int n, k, cnt[N], son[N];
int e_cnt, heads[N];
bool key[N];
ll f[N], g[N], len[N], slen[N];

struct Edge {
  int v, nxt, w;
} e[N << 1];

inline void add(int u, int v, int w) {
  e[++e_cnt].v = v, e[e_cnt].nxt = heads[u], heads[u] = e_cnt, e[e_cnt].w = w;
}

void dfs1(int x, int fa) {
  if (key[x]) cnt[x] = 1;
  for (int i = heads[x], v; i; i = e[i].nxt) {
    if ((v = e[i].v) != fa) {
      dfs1(v, x);
      if (cnt[v]) {
        g[x] += g[v] + (e[i].w << 1);
        ll tmp = len[v] + e[i].w;
        if (tmp >= len[x])
          slen[x] = len[x], len[x] = tmp, son[x] = v;
        else if (tmp > slen[x])
          slen[x] = tmp;
      }
      cnt[x] += cnt[v];
    }
  }
}

void dfs2(int x, int fa) {
  for (int i = heads[x], v; i; i = e[i].nxt) {
    if ((v = e[i].v) != fa) {
      if (!cnt[v])
        f[v] = f[x] + (e[i].w << 1), len[v] = len[x] + e[i].w;
      else if (cnt[v] == k)
        f[v] = g[v];
      else {
        f[v] = f[x];
        if (son[x] != v && len[v] <= len[x] + e[i].w)
          slen[v] = len[v], son[v] = x, len[v] = len[x] + e[i].w;
        else if (len[v] <= slen[x] + e[i].w)
          slen[v] = len[v], son[v] = x, len[v] = slen[x] + e[i].w;
        else if (son[x] != v && slen[v] < len[x] + e[i].w)
          slen[v] = len[x] + e[i].w;
        else if (slen[v] < slen[x] + e[i].w)
          slen[v] = slen[x] + e[i].w;
      }
      dfs2(v, x);
    }
  }
}
int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
  freopen("P6419 Kamp.in", "r", stdin);
  freopen("P6419 Kamp.out", "w", stdout);
#endif
#endif

  scanf("%d%d", &n, &k);
  for (int i = 1, x, y, z; i < n; ++i) {
    scanf("%d%d%d", &x, &y, &z);
    add(x, y, z), add(y, x, z);
  }
  for (int i = 1, tmp; i <= k; ++i) {
    scanf("%d", &tmp), key[tmp] = true;
  }
  dfs1(1, 1);
  f[1] = g[1];
  dfs2(1, 1);
  for (int i = 1; i <= n; ++i) printf("%lld\n", f[i] - len[i]);
  return 0;
}